print(hashTable) |
hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
else: |
hashTable[idx] = i |
if hashTable[idx] == None: |
for i in itemsToAdd: |
idx = i % 20 |
itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
print("Collision: " + str(i)) |
print(hashTable) |
hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
else: |
hashTable[idx] = i |
if hashTable[idx] == None: |
for i in itemsToAdd: |
idx = i % 20 |
itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
print("Collision: " + str(i)) |
1 | hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
2 | itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
3 | |
4 | for i in itemsToAdd: |
5 | idx = i % 20 |
6 | if hashTable[idx] == None: |
7 | hashTable[idx] = i |
8 | else: |
9 | print("Collision: " + str(i)) |
10 | |
11 | print(hashTable) |
break |
hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
print(hashTable) |
idx = i % 20 |
for x in range(len(hashTable)): |
tempIdx = 0 |
itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
if tempIdx == 20: |
if hashTable[tempIdx] == None: |
for i in itemsToAdd: |
hashTable[tempIdx] = i |
tempIdx = idx + x |
break |
hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
print(hashTable) |
idx = i % 20 |
for x in range(len(hashTable)): |
tempIdx = 0 |
itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
if tempIdx == 20: |
if hashTable[tempIdx] == None: |
for i in itemsToAdd: |
hashTable[tempIdx] = i |
tempIdx = idx + x |
1 | hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
2 | itemsToAdd = [18,45,77,81,11,96,52,14,56,99,5] |
3 | |
4 | for i in itemsToAdd: |
5 | idx = i % 20 |
6 | for x in range(len(hashTable)): |
7 | tempIdx = idx + x |
8 | if tempIdx == 20: |
9 | tempIdx = 0 |
10 | if hashTable[tempIdx] == None: |
11 | hashTable[tempIdx] = i |
12 | break |
13 | print(hashTable) |
for n in name: |
if hashTable[tempIdx] == None: |
for name in itemsToAdd: |
def hashFunction(name): |
hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
return t |
itemsToAdd = ["Harry","Sebastian","Greg","Julia","Karen","Jamie","Gordon","Georgia","Zane"] |
t = t % 20 |
t = 0 |
hashTable[tempIdx] = name |
for x in range(len(hashTable)): |
print(hashTable) |
print(idx) |
t = t + ord(n) |
idx = hashFunction(name) |
if tempIdx == 20: |
break |
tempIdx = idx + x |
tempIdx = 0 |
for n in name: |
if hashTable[tempIdx] == None: |
for name in itemsToAdd: |
def hashFunction(name): |
hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
return t |
itemsToAdd = ["Harry","Sebastian","Greg","Julia","Karen","Jamie","Gordon","Georgia","Zane"] |
t = t % 20 |
t = 0 |
hashTable[tempIdx] = name |
for x in range(len(hashTable)): |
print(hashTable) |
print(idx) |
t = t + ord(n) |
idx = hashFunction(name) |
if tempIdx == 20: |
break |
tempIdx = idx + x |
tempIdx = 0 |
1 | hashTable = [None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None] |
2 | itemsToAdd = ["Harry","Sebastian","Greg","Julia","Karen","Jamie","Gordon","Georgia","Zane"] |
3 | |
4 | def hashFunction(name): |
5 | t = 0 |
6 | for n in name: |
7 | t = t + ord(n) |
8 | t = t % 20 |
9 | return t |
10 | |
11 | for name in itemsToAdd: |
12 | idx = hashFunction(name) |
13 | print(idx) |
14 | for x in range(len(hashTable)): |
15 | tempIdx = idx + x |
16 | if tempIdx == 20: |
17 | tempIdx = 0 |
18 | if hashTable[tempIdx] == None: |
19 | hashTable[tempIdx] = name |
20 | break |
21 | print(hashTable) |
strid = str(key["id"]) |
if hashTable[tempIdx] == None: |
break |
hashTable[tempIdx] = dictionary |
idx = hashFunction(dictionary) |
return t % 64 |
for dictionary in itemsToAdd: |
def hashFunction(key): |
for x in range(len(hashTable)): |
tempIdx = (idx + x) % 64 |
t = 0 |
print(idx) |
t = t + int(strid[i]) |
print(hashTable) |
for i in range(len(strid)): |
strid = str(key["id"]) |
if hashTable[tempIdx] == None: |
break |
hashTable[tempIdx] = dictionary |
idx = hashFunction(dictionary) |
return t % 64 |
for dictionary in itemsToAdd: |
def hashFunction(key): |
for x in range(len(hashTable)): |
tempIdx = (idx + x) % 64 |
t = 0 |
print(idx) |
t = t + int(strid[i]) |
print(hashTable) |
for i in range(len(strid)): |
1 | def hashFunction(key): |
2 | t = 0 |
3 | strid = str(key["id"]) |
4 | for i in range(len(strid)): |
5 | t = t + int(strid[i]) |
6 | return t % 64 |
7 | |
8 | |
9 | for dictionary in itemsToAdd: |
10 | idx = hashFunction(dictionary) |
11 | print(idx) |
12 | for x in range(len(hashTable)): |
13 | tempIdx = (idx + x) % 64 |
14 | if hashTable[tempIdx] == None: |
15 | hashTable[tempIdx] = dictionary |
16 | break |
17 | print(hashTable) |
break |
print(hashTable) |
key = "0" + key |
return t % 64 |
if hashTable[tempIdx] == None: |
t = 1 |
for dictionary in itemsToAdd: |
while len(key) % 4 != 0: |
tempIdx = (idx + x) % 64 |
def hashFunction(key): |
hashTable[tempIdx] = dictionary |
part = key[4*x:4*(x+1)] |
key = str(key["id"]) |
for x in range(len(key)//4): |
t = t * int(part) |
idx = hashFunction(dictionary) |
for x in range(len(hashTable)): |
break |
print(hashTable) |
key = "0" + key |
return t % 64 |
if hashTable[tempIdx] == None: |
t = 1 |
for dictionary in itemsToAdd: |
while len(key) % 4 != 0: |
tempIdx = (idx + x) % 64 |
def hashFunction(key): |
hashTable[tempIdx] = dictionary |
part = key[4*x:4*(x+1)] |
key = str(key["id"]) |
for x in range(len(key)//4): |
t = t * int(part) |
idx = hashFunction(dictionary) |
for x in range(len(hashTable)): |
1 | def hashFunction(key): |
2 | key = str(key["id"]) |
3 | while len(key) % 4 != 0: |
4 | key = "0" + key |
5 | for x in range(len(key)//4): |
6 | t = 1 |
7 | part = key[4*x:4*(x+1)] |
8 | t = t * int(part) |
9 | return t % 64 |
10 | |
11 | for dictionary in itemsToAdd: |
12 | idx = hashFunction(dictionary) |
13 | for x in range(len(hashTable)): |
14 | tempIdx = (idx + x) % 64 |
15 | if hashTable[tempIdx] == None: |
16 | hashTable[tempIdx] = dictionary |
17 | break |
18 | print(hashTable) |
key = str(key["id"]) |
part = key[4*x:4*(x+1)] |
hashTable = [None]*num |
break |
if collision == False: |
print(num) |
collision = False |
idx = hashFunction(dictionary,num) |
t = t * int(part) |
while len(key) % 4 != 0: |
break |
def hashFunction(key,size): |
break |
hashTable[tempIdx] = dictionary |
tempIdx = (idx + x) % num |
for num in range(64,150): |
key = "0" + key |
for x in range(len(hashTable)): |
if hashTable[tempIdx] == None: |
t = 1 |
return t % size |
for x in range(len(key)//4): |
if collision == True: |
for dictionary in itemsToAdd: |
if x == 1: |
collision = True |
key = str(key["id"]) |
part = key[4*x:4*(x+1)] |
hashTable = [None]*num |
break |
if collision == False: |
print(num) |
collision = False |
idx = hashFunction(dictionary,num) |
t = t * int(part) |
while len(key) % 4 != 0: |
break |
def hashFunction(key,size): |
break |
hashTable[tempIdx] = dictionary |
tempIdx = (idx + x) % num |
for num in range(64,150): |
key = "0" + key |
for x in range(len(hashTable)): |
if hashTable[tempIdx] == None: |
t = 1 |
return t % size |
for x in range(len(key)//4): |
if collision == True: |
for dictionary in itemsToAdd: |
if x == 1: |
collision = True |
1 | def hashFunction(key,size): |
2 | key = str(key["id"]) |
3 | while len(key) % 4 != 0: |
4 | key = "0" + key |
5 | for x in range(len(key)//4): |
6 | t = 1 |
7 | part = key[4*x:4*(x+1)] |
8 | t = t * int(part) |
9 | return t % size |
10 | |
11 | for num in range(64,150): |
12 | hashTable = [None]*num |
13 | collision = False |
14 | for dictionary in itemsToAdd: |
15 | idx = hashFunction(dictionary,num) |
16 | for x in range(len(hashTable)): |
17 | if x == 1: |
18 | collision = True |
19 | break |
20 | tempIdx = (idx + x) % num |
21 | if hashTable[tempIdx] == None: |
22 | hashTable[tempIdx] = dictionary |
23 | break |
24 | if collision == True: |
25 | break |
26 | if collision == False: |
27 | print(num) |